#ifndef USERIAL_DEFMT_H
#define USERIAL_DEFMT_H

#include "CtrlLib/CtrlLib.h"
//#include "FileWatch.hpp"

using namespace Upp;

namespace Defmt 
{
struct LogArg: Moveable<LogArg>
{
    LogArg() {  }
    String name;
    Value value;   
};

struct LogItem: Moveable<LogItem>
{
    LogItem() { }
    int str_id;
    // String str;
    Vector<LogArg> args;

    String GetData();
};

class LogIdManager
{
public:
    LogIdManager() { }
    ~LogIdManager() { }

    int Add(String &str, int id);
    int GetId(String &str);
    int GetStr(int id);
private:
    VectorMap<String, int> idmap;
};

class LogManager
{
public:
    typedef LogManager CLASSNAME;
    LogManager();
    ~LogManager();

    void SetPath(String &path);
    void Parse();
    void SaveFile();
    void ParseCSVFile();
    void ParsePath();
    void ParseFile(String &file);
    //void OnFileChange(const std::wstring& file, const filewatch::Event event_type);
    

private:
    String path;
    Vector<LogItem> logitems;
    LogIdManager idmanager;

    //filewatch::FileWatch<std::wstring> *watch = nullptr;
};

}

#endif
